package com.cskaoyan.service;

import com.cskaoyan.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

/**
 * @author stone
 * @date 2022/09/30 11:36
 */
//@Component // 组件id → userServiceImpl
@Component("userService")
public class UserServiceImpl implements UserService{

    UserDao userDao;
    DataSource dataSource;

    //UnsatisfiedDependencyException
    /*public UserServiceImpl(UserDao userDao,DataSource dataSource) {
        this.userDao = userDao;
        this.dataSource = dataSource;
    }*/

    public UserServiceImpl(UserDao userDao,  @Qualifier("dataSource2") DataSource dataSource) {
        this.userDao = userDao;
        this.dataSource = dataSource;
    }

    @Override
    public void method1() {
        System.out.println("method1");
    }
}
